<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">
        <h2>项目详情</h2>
        <div class="layui-btn-container">
            <a href="<?php echo \yii\helpers\Url::to(['index']); ?>" class="layui-btn layui-btn-sm layui-btn-primary"><i class="layui-icon layui-icon-left"></i>返回列表</a>
            <a href="<?php echo \yii\helpers\Url::to(['show','id'=>$model->id]); ?>" class="layui-btn layui-btn-sm"><i class="layui-icon layui-icon-template"></i>项目详情</a>
            <a href="<?php echo \yii\helpers\Url::to(['node','id'=>$model->id]); ?>" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon layui-icon-engine"></i>更新节点</a>
            <a href="<?php echo \yii\helpers\Url::to(['remark','id'=>$model->id]); ?>" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon layui-icon-form"></i>添加备注</a>
            <a id="destroyBtn" data-url="<?php echo \yii\helpers\Url::to(['destroy','id'=>$model->id]); ?>" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon layui-icon-delete"></i>删除</a>
        </div>
    </div>
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-xs5">
                <div class="layui-card">
                    <div class="layui-card-header"><b>客户信息</b></div>
                    <div class="layui-card-body">
                        <table class="layui-table" lay-skin="nob">
                            <tbody>
                            <tr>
                                <td width="80" align="right">客户姓名：</td>
                                <td><?php echo $model->name; ?></td>
                                <td width="80" align="right">客户性别：</td>
                                <td><?php echo $model->sexText; ?></td>
                            </tr>
                            <tr>
                                <td width="80" align="right">联系电话：</td>
                                <td><?php echo $model->phone; ?></td>
                                <td width="80" align="right">其它电话：</td>
                                <td><?php echo $model->other_phone; ?></td>
                            </tr>
                            <tr>
                                <td width="80" align="right">公司名称：</td>
                                <td><?php echo $model->company; ?></td>
                                <td width="80" align="right">当前节点：</td>
                                <td><?php echo $model->node->name; ?></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs5 layui-col-lg-offset2">
                <div class="layui-card">
                    <div class="layui-card-header"><b>跟进信息</b></div>
                    <div class="layui-card-body">
                        <table class="layui-table" lay-skin="nob">
                            <tbody>
                            <tr>
                                <td width="80" align="right">跟进时间：</td>
                                <td><?php echo $follow['follow_at']?date('Y-m-d H:i',$follow['follow_at']):'-'; ?></td>
                                <td width="80" align="right">跟进人：</td>
                                <td><?php echo $follow['username']; ?></td>
                            </tr>
                            <tr>
                                <td width="80" align="right">下次跟进：</td>
                                <td colspan="3"><?php echo $follow['next_follow_at']?date('Y-m-d H:i',$follow['next_follow_at']):'-'; ?></td>
                            </tr>
                            <tr>
                                <td width="80" align="right">跟进备注：</td>
                                <td  colspan="3"><?php echo $follow['content']; ?></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs6">
                <div class="layui-card">
                    <div class="layui-card-header"><b>节点进度</b></div>
                    <div class="layui-card-body">
                        <table id="dataTableNode" lay-filter="dataTableNode"></table>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="layui-card">
                    <div class="layui-card-header"><b>备注进度</b></div>
                    <div class="layui-card-body">
                        <table id="dataTableRemark" lay-filter="dataTableRemark"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<?php
$index_url = \yii\helpers\Url::to(['index']);
$node_url = \yii\helpers\Url::to(['node-list','id'=>$model->id]);
$remark_url = \yii\helpers\Url::to(['remark-list','id'=>$model->id]);
$js = <<<JS
    layui.use(['form','element','table', 'layer'],function() {
        var form = layui.form;  
        var element = layui.element;  
        var table = layui.table;  
        var layer = layui.layer;  
        
        //节点进度
        var dataTable = table.render({
            elem: '#dataTableNode'
            ,height: '480'
            ,url: '{$node_url}' 
            ,page: true 
            ,toolbar: false 
            ,cols: [[ 
                {type: 'checkbox'}
                ,{field: 'old', title: '原节点'}
                ,{field: 'new', title: '新节点'}
                ,{field: 'content', title: '备注'}
                ,{field: 'username', title: '操作人'}
                ,{field: 'created_at', title: '操作时间'}
            ]]
        });
        
        //备注进度
        var dataTable = table.render({
            elem: '#dataTableRemark'
            ,height: '480'
            ,url: '{$remark_url}' 
            ,page: true 
            ,toolbar: false 
            ,cols: [[ 
                {type: 'checkbox'}
                ,{field: 'content', title: '备注'}
                ,{field: 'created_at', title: '跟进时间'}
                ,{field: 'next_follow_at', title: '下次跟进时间'}
                ,{field: 'username', title: '跟进人'}
            ]]
        });
        
        $("#destroyBtn").click(function() {
            var url = $(this).data('url')
            layer.confirm('确认删除吗？', function(index){
                $.post(url,{},function(res) {
                    layer.msg(res.msg,{},function() {
                        if (res.code==0){
                            location.href = '{$index_url}'
                        }   
                    })  
                })
            });  
        })
    });
JS;
$this->registerJs($js);
